#ifndef __CPUPORT_H__
#define __CPUPORT_H__

#include "microThread.h"

#ifdef __cplusplus
extern "C" {
#endif

#define HW_MAX_CPU_TICK 0xffffffff

mt_ubase_t *hw_stack_init(void *entry, void *parameter, mt_ubase_t *stack_addr);

mt_base_t hw_interrupt_save(void);
void hw_interrupt_restore(mt_base_t status);
mt_base_t hw_interrupt_status(void);

void hw_context_switch(mt_ubase_t *from_sp, mt_ubase_t *to_sp);
void hw_context_switch_start(mt_ubase_t *start_sp);

void hw_cpu_tick_init(void);
mt_tick_t hw_cpu_get_tick(void);
mt_uint64_t hw_cpu_tick_to_us(mt_uint64_t cpu_tick);
void hw_delay_us(mt_ubase_t us);

mt_int32_t hw_ffs(mt_uint32_t value);
void *hw_thread_exit(void);

#ifdef __cplusplus
}
#endif

#endif
